﻿using System.Text;

namespace msilgc.cbuilder.CSyntaxTree
{
    internal class StoreArrayElementStatement : ICStatement {
        public IVariable TargetArray { get; set; }
        public IVariable Index { get; set; }
        public IVariable Source { get; set; }

        public StoreArrayElementStatement(IVariable targetArray, IVariable index, IVariable source) {
            TargetArray = targetArray;
            Index = index;
            Source = source;
        }

        public void Emit(StringBuilder builder) {
            TargetArray.Emit(builder);
            builder.Append(".array_data[");
            Index.Emit(builder);
            builder.Append("] = ");
            Source.Emit(builder);
            builder.AppendLine(";");
        }
    }
}